//package com.ls.markt.service.admin.impl;
//
//import com.ls.markt.dao.admin.PlayerMapper;
//import com.ls.markt.dto.PlayerImportDTO;
//import com.ls.markt.model.admin.Player;
//import com.ls.markt.repository.admin.PlayerRepository;
//import com.ls.markt.service.admin.ClubService;
//import com.ls.markt.service.admin.PlayerService;
//import com.ls.markt.util.ExcelUtil;
//import org.springframework.beans.BeanUtils;
//import org.springframework.data.domain.Page;
//import org.springframework.data.domain.PageRequest;
//import org.springframework.stereotype.Service;
//import org.springframework.web.multipart.MultipartFile;
//
//import javax.annotation.Resource;
//import java.io.IOException;
//import java.util.List;
//import java.util.Map;
//
//@Service
//public class PlayerServiceImpl implements PlayerService {
//
//    @Resource
//    private PlayerMapper mapper;
//
//    @Resource
//    private PlayerRepository playerRepository;
//
//    @Resource
//    private ClubService clubService;
//
//    @Override
//    public Page<Player> findAll(PageRequest pageRequest) {
//        return playerRepository.findAll(pageRequest);
//    }
//
//    @Override
//    public void savePlayer(Player player) {
//        playerRepository.save(player);
//    }
//
////    @Override
////    public void updatePlayer(Player player) {
////        mapper.update(player);
////    }
//
//    @Override
//    public Player getPlayerById(Long id) {
//        return playerRepository.getOne(id);
//    }
//
//    @Override
//    public void removePlayer(Long id) {
//        playerRepository.deleteById(id);
//    }
//
//    /**
//     * 根据俱乐部ID获取所有球员
//     * @param clubId
//     * @return
//     */
//    @Override
//    public List<Player> listPlayersByClubId(Long clubId) {
//        //return mapper.findByClub(clubId);
//        return playerRepository.findByClub(clubId);
//    }
//
//    @Override
//    public Map<String, Object> listInfoByClub(Long clubId) {
//        return mapper.findInfoByClub(clubId);
//    }
//
////    @Override
////    public void importExcel(MultipartFile file) throws IOException {
////        List<Object> players = ExcelUtil.readExcel(file, Player.class);
////        for (Object o: players){
////            Player player = (Player) o;
////            playerRepository.save(player);
////        }
////    }
//
//    @Override
//    public void importExcel(MultipartFile file) throws IOException {
//        List<Object> playerDTOs = ExcelUtil.readExcel(file, PlayerImportDTO.class);
//        for (Object o: playerDTOs){
//            PlayerImportDTO playerImportDTO = (PlayerImportDTO) o;
//            String clubName = playerImportDTO.getClubName();
//            Long clubId = clubService.getIdByName(clubName);
//            if (clubId!=null){
//                Player player = new Player();
//                BeanUtils.copyProperties(playerImportDTO,player);
//                player.setClub(clubId);
//                playerRepository.save(player);
//            }
////            playerRepository.save(player);
//        }
//    }
//}
